<template>
  <div class="list">
    <div class="list-scroll">
      <div
        v-for="(item) in PLACELIST"
        class="address-box error-box"
        v-bind:class="{'choose':placeCode===item.placeCode}"
        :key="item.placeCode"
        v-if="item.isError===1"
        @click="showList(item.placeCode)"
        >
      <div class="box-head">{{item.placeName}}</div>
      <div class="box-msg">
        <div class="box-left">
          <div class="dev-number">
            <span>{{item.devNum}}</span>台
          </div>
          <div class="box-bottom-msg">设备数量</div>
        </div>
 <!--       <div class="box-right">
          <div class="dev-number">
            <span>{{item.flow}}</span>G
          </div>
          <div class="box-bottom-msg">可用流量</div>
        </div>-->
      </div>
    </div>
      <div
        v-for="item in PLACELIST"
        class="address-box"
        v-bind:class="{'choose':placeCode===item.placeCode}"
        :key="item.placeCode"
        v-if="item.isError === 0"
        @click="showList(item.placeCode)"
      >  <div class="box-head">{{item.placeName, item.flowError}}</div>
        <div class="box-msg">
          <div class="box-left">
            <div class="dev-number">
              <span>{{item.devNum}}</span>台
            </div>
            <div class="box-bottom-msg">设备数量</div>
          </div>
<!--          <div class="box-right">
            <div class="dev-number">
              <span>{{item.flow}}</span>G
            </div>
            <div class="box-bottom-msg">可用流量</div>
          </div>-->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {EXCEDEV} from '../../api/request'
import { Toast } from 'vue-ydui/dist/lib.rem/dialog'
export default {
  name: 'head',
  data () {
    return {
      PLACELIST: [],
      placeCode: ''
    }
  },
  created () {
    let uid = this.$store.state.user.userId
    EXCEDEV(uid).then(res => {
      if (res.data.code === 200) {
        this.PLACELIST = res.data.data
        for (let index in this.PLACELIST) {
          let item = this.PLACELIST[index]
          if (item.isErrow) {
            this.$emit('getDev', item.placeCode, item.flowErrow)
            this.placeCode = item.placeCode
            return
          }
        }
      } else {
        Toast(res.data.msg)
      }
    })
  },
  methods: {
    showList (placeCode, flowError) {
      this.placeCode = placeCode
      this.$emit('getDev', placeCode, flowError)
    }
  }
}
</script>

<style scoped>
@import "../../assets/css/select.css";
</style>
